//
//  CollectionViewController.m
//  Lovelife
//
//  Created by dllo on 15/4/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "CollectionViewController.h"
#import "AppreciationCollection.h"
#import "SavourCollection.h"
#import "SightseeinCollection.h"
#import "BaseTableViewCell.h"
#import "NightManager.h"
@interface CollectionViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, retain) NSArray *arrayOfTitle;
@property (nonatomic, retain) NSArray *arrayOfVC;
@property (nonatomic, retain) UITableView *tableView;

@end

@implementation CollectionViewController
- (void)dealloc
{
    [_arrayOfTitle release];
    [_arrayOfVC release];
    [_tableView release];
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.arrayOfTitle = @[@"爱赏收藏",@"爱品收藏",@"爱游收藏"];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    AppreciationCollection *collection = [[AppreciationCollection alloc]init];
    SavourCollection *savour = [[SavourCollection alloc]init];
    SightseeinCollection *sightseein = [[SightseeinCollection alloc] init];
    self.arrayOfVC = [NSArray arrayWithObjects:collection,savour,sightseein, nil];
    [collection release];
    [savour release];
    [sightseein release];

    // 创建列表
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
    [NightManager setBackgroundColorWithView:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView release];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arrayOfTitle.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse = @"reuse";
    BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[BaseTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse] autorelease];
    }
    cell.textLabel.text = self.arrayOfTitle[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController *vc = self.arrayOfVC[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)setLightDayModel
{
    [NightManager setBackgroundColorWithView:self.view];
    [NightManager setBackgroundColorWithView:self.tableView];

}
- (void)setNightDayModel
{
    [NightManager setBackgroundColorWithView:self.view];
    [NightManager setBackgroundColorWithView:self.tableView];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
